from django.shortcuts import render
from demo1 import models,serializer
from rest_framework import viewsets
from rest_framework.pagination import  PageNumberPagination
from django_filters import filters,FilterSet
from django_filters.rest_framework import DjangoFilterBackend


# Create your views here.

class MyPage(PageNumberPagination):
    page_size_query_param = 'size'

class MyFilterset(FilterSet):
    class Meta:
        fields=['teacher','name','numbers']
        model=models.Myclass

class MyClass(viewsets.ModelViewSet):
    queryset = models.Myclass.objects.all()
    serializer_class = serializer.Myclass

    filter_backends = [DjangoFilterBackend]
    pagination_class = MyPage
    filterset_class=MyFilterset

class Teacher(viewsets.ModelViewSet):
    queryset = models.Teacher.objects.all()
    serializer_class = serializer.Teacher


